package com.cqupt.scanning.system.file.helper;

import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import com.cqupt.scanning.system.admin.entity.FeatureData;
import com.cqupt.scanning.system.admin.entity.PatientFoot;
import com.cqupt.scanning.system.admin.entity.PatientThree;
import com.cqupt.scanning.system.file.entity.bo.MesurementBO;
import com.cqupt.scanning.system.utils.common.StringToDateConverter;

import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Data: 2021/7/7 16:58
 * @Author: 宋宝梁
 */
public class DataSet {

    private String id = "";

    public DataSet() {
        this.id = IdUtil.simpleUUID();
    }

    /**
     * 足底扫描报告所需数据
     * @param patient
     * @param featureData
     * @return
     */
    public Map<String, String> getDataMapOfGait(PatientFoot patient, FeatureData featureData) {
        Map<String, String> map = new HashMap<>();
        /**
         * 基本资料
         */
        map.put("id", this.id);
        map.put("name", patient.getName());
        map.put("sex", patient.getSex());
        map.put("year", getDate(patient.getBirthDate()).get("year"));
        map.put("month", getDate(patient.getBirthDate()).get("month"));
        map.put("day", getDate(patient.getBirthDate()).get("day"));
        map.put("birthDate", patient.getBirthDate());
        map.put("heigth", patient.getHeight());
        map.put("weigth", patient.getWeight());
        map.put("phone", patient.getPhone());

        map.put("gaitMode", patient.getGaitMeasureMode());
//        System.out.println("--------------------");
//        System.out.println(patient.getGaitMeasureMode());
//        System.out.println("--------------------");
        // 检测模式
        switch (patient.getGaitMeasureMode()) {
            case "步态测量:非折返模式" :
                map.put("nonReturnMode", "√");
                break;
            case "步态测量:折返模式" :
                map.put("returnMode", "√");
                break;
            case "步态测量:行走模式" :
                map.put("walkingMode", "√");
                break;
            case "步态测量:跑步机模式" :
                map.put("treadmillMode", "√");
        }

        /**
         * 基础数据
         */
        map.put("average_time", getAverageTime(featureData.getRundurationtimeLeft(), featureData.getRundurationtimeRight()));
        map.put("average_speed", getAverageSpeed(featureData.getStepSpeedLeft(), featureData.getStepSpeedRight()));
        map.put("step_frequency_left", getTwoDigits(featureData.getStepFrequencyLeft()));
        map.put("step_frequency_right", getTwoDigits(featureData.getStepFrequencyRight()));
        map.put("step_distance_left", getTwoDigits(featureData.getStepDistanceLeftMean()) );
        map.put("step_distance_right", getTwoDigits(featureData.getStepDistanceRightMean()));
        map.put("step_high_left", getTwoDigits(featureData.getStepHighLeftMean()));
        map.put("step_high_right", getTwoDigits(featureData.getStepHighRightMean()));
        map.put("step_width_left", getTwoDigits(featureData.getStepWidthLeftMean()));
        map.put("step_width_right", getTwoDigits(featureData.getStepWidthRightMean()));
        map.put("load_angle_left", getTwoDigits(featureData.getLoadAngleLeftMean()));
        map.put("load_angle_right", getTwoDigits(featureData.getLoadAngleRightMean()));
        map.put("preswing_angle_left", getTwoDigits(featureData.getPreswingAngleLeftMean()));
        map.put("preswing_angle_right", getTwoDigits(featureData.getPreswingAngleRightMean()));

        /**
         * 步态周期检测
         */
        map.put("mdgp_l", getGaitCycleInfo(featureData).get(0));
        map.put("mdgp_r", getGaitCycleInfo(featureData).get(1));
        map.put("adcpq_l", getGaitCycleInfo(featureData).get(2));
        map.put("adcpq_r", getGaitCycleInfo(featureData).get(3));
        map.put("admpq_l", getGaitCycleInfo(featureData).get(4));
        map.put("admpq_r", getGaitCycleInfo(featureData).get(5));
        map.put("adppq_l", getGaitCycleInfo(featureData).get(6));
        map.put("adppq_r", getGaitCycleInfo(featureData).get(7));
        map.put("adspq_l", getGaitCycleInfo(featureData).get(8));
        map.put("adspq_r", getGaitCycleInfo(featureData).get(9));


        /**
         * 压力组合分析
         */
        map.put("jd_one_to_nine_apzn_left", getMeanPressure(featureData).get(2));
        map.put("jd_one_to_nine_apzn_right", getMeanPressure(featureData).get(3));

        map.put("jd1_apr_left", getMeanPressure(featureData).get(4));
        map.put("jd2_apr_left", getMeanPressure(featureData).get(5));
        map.put("jd3_apr_left", getMeanPressure(featureData).get(6));
        map.put("jd4_apr_left", getMeanPressure(featureData).get(7));
        map.put("jd5_apr_left", getMeanPressure(featureData).get(8));
        map.put("jd6_apr_left", getMeanPressure(featureData).get(9));
        map.put("jd7_apr_left", getMeanPressure(featureData).get(10));
        map.put("jd8_apr_left", getMeanPressure(featureData).get(11));
        map.put("jd9_apr_left", getMeanPressure(featureData).get(12));
        map.put("jd1_apr_right", getMeanPressure(featureData).get(13));
        map.put("jd2_apr_right", getMeanPressure(featureData).get(14));
        map.put("jd3_apr_right", getMeanPressure(featureData).get(15));
        map.put("jd4_apr_right", getMeanPressure(featureData).get(16));
        map.put("jd5_apr_right", getMeanPressure(featureData).get(17));
        map.put("jd6_apr_right", getMeanPressure(featureData).get(18));
        map.put("jd7_apr_right", getMeanPressure(featureData).get(19));
        map.put("jd8_apr_right", getMeanPressure(featureData).get(20));
        map.put("jd9_apr_right", getMeanPressure(featureData).get(21));

        map.put("jd_four_to_six_apzn_left", getMeanPressure(featureData).get(22));
        map.put("jd_four_to_six_apzn_right", getMeanPressure(featureData).get(23));
        map.put("jd_four_to_six_apr_left", getMeanPressure(featureData).get(24));
        map.put("jd_four_to_six_apr_right", getMeanPressure(featureData).get(25));

        map.put("jd_one_two_eight_nine_apzn_left", getMeanPressure(featureData).get(26));
        map.put("jd_one_two_eight_nine_apzn_right", getMeanPressure(featureData).get(27));
        map.put("jd_one_two_eight_nine_apr_left", getMeanPressure(featureData).get(28));
        map.put("jd_one_two_eight_nine_apr_right", getMeanPressure(featureData).get(29));

        map.put("jd_ylzhr", getMeanPressure(featureData).get(30));

        map.put("cpq_mlp_ylzhr_left",getMeanPressure(featureData).get(31));
        map.put("cpq_mlp_ylzhr_right",getMeanPressure(featureData).get(32));
        map.put("mpq_mlp_ylzhr_left",getMeanPressure(featureData).get(33));
        map.put("mpq_mlp_ylzhr_right",getMeanPressure(featureData).get(34));
        map.put("cmpq_mlp_ylzhr_left",getMeanPressure(featureData).get(35));
        map.put("cmpq_mlp_ylzhr_right",getMeanPressure(featureData).get(36));

        map.put("mlp_ylzhr_left",getMeanPressure(featureData).get(37));
        map.put("mlp_ylzhr_right",getMeanPressure(featureData).get(38));

        /**
         * 站立相
         */
        map.put("sdp_left",getGaitSDPinfo(featureData).get(0));
        map.put("sdp_right",getGaitSDPinfo(featureData).get(1));

        /**
         * 后跟角速度
         */
        map.put("hvnf_czwar_left",getGaitHeelPalstanceInfo(featureData).get(0));
        map.put("hvw_zdwfar_left",getGaitHeelPalstanceInfo(featureData).get(1));
        map.put("hvnf_zdwfar_left",getGaitHeelPalstanceInfo(featureData).get(2));
        map.put("hvnf_czwar_right",getGaitHeelPalstanceInfo(featureData).get(3));
        map.put("hvw_zdwfar_right",getGaitHeelPalstanceInfo(featureData).get(4));
        map.put("hvnf_zdwfar_right",getGaitHeelPalstanceInfo(featureData).get(5));

        map.put("hvnf_zdnfar_left",getGaitHeelPalstanceInfo(featureData).get(6));
        map.put("hvnf_zdnfar_right",getGaitHeelPalstanceInfo(featureData).get(7));

        /**
         * 图片
         */
        map.put("imageLeft", null);
        map.put("imageRight", null);
        map.put("normal", null);
        map.put("cop", null);
        map.put("MaxFPAleft",null);
        map.put("MaxFPAright",null);
        map.put("MinFPAleft",null);
        map.put("MinFPAright",null);


        /**
         * 步偏脚分析
         */
        map.put("fpa_left", getTwoDigits(featureData.getFpaLeftMean()));
        map.put("fpa_right", getTwoDigits(featureData.getFpaRightMean()));
        map.put("max_fpa_left",getTwoDigits(featureData.getMaxFpaLeft()) );
        map.put("max_fpa_right", getTwoDigits(featureData.getMaxFpaRight()));
        map.put("min_fpa_left", getTwoDigits(featureData.getMinFpaLeft()));
        map.put("min_fpa_right", getTwoDigits(featureData.getMinFpaRight()));

        /**
         * 距下关节运动检测
         */
        map.put("c_left_mean", getTwoDigits(featureData.getCLeftMean()));
        map.put("c_right_mean", getTwoDigits(featureData.getCRightMean()));
        map.put("t3_left_mean", getTwoDigits(featureData.getT3LeftMean()));
        map.put("t3_right_mean", getTwoDigits(featureData.getT3RightMean()));

        return map;
    }

    /**
     * 平衡测试报告所需数据
     * @param patient
     * @return
     */
    public Map<String, String> getDataMapOfBalance(PatientFoot patient) {
        Map<String, String> map = new HashMap<>();
        /**
         * 基本资料
         */
        map.put("id", this.id);
        map.put("name", patient.getName());
        map.put("sex", patient.getSex());
        map.put("year", getDate(patient.getBirthDate()).get("year"));
        map.put("month", getDate(patient.getBirthDate()).get("month"));
        map.put("day", getDate(patient.getBirthDate()).get("day"));
        map.put("heigth", patient.getHeight());
        map.put("weigth",patient.getWeight());
        map.put("phone", patient.getPhone());

        map.put("balanceMode", patient.getGaitMeasureMode());
        // 检测模式

        switch (patient.getGaitMeasureMode()) {
            case "步态测量:行走模式" :
                map.put("returnMode", "√");
                break;
            case "步态测量:跑步机模式" :
                map.put("treadmillmode", "√");
                break;
            case "步态测量:站立睁眼模式" :
                map.put("standingEyesOpenMode", "√");
                break;
            case "步态测量:站立闭眼模式" :
                map.put("standingClosedEyesMode", "√");
                break;
            case "步态测量:单足睁眼模式(左)" :
                map.put("oneFootOpenLeftEyeMode", "√");
                break;
            case "步态测量:单足睁眼模式(右)" :
                map.put("oneFootOpenRightEyesMode", "√");
                break;
            case "步态测量:单足闭眼模式(左)" :
                map.put("oneFootClosedLeftEyesMode", "√");
                break;
            case "步态测量:单足闭眼模式(右)" :
                map.put("oneFootClosedRightEyesMode", "√");
                break;
            case "步态测量:上坡/上楼梯模式" :
                map.put("uphillMode", "√");
                break;
            case "步态测量:下坡/下楼梯模式" :
                map.put("downhillMode", "√");
        }

        /**
         * 图片
         */
        map.put("balance", null);
        map.put("foreHind", null);
        map.put("inout", null);
        map.put("offset", null);
        map.put("averagePercentage", null);
        map.put("averagePressure", null);
        map.put("foreFoot", null);
        map.put("hindFoot", null);
        map.put("midFoot", null);
        map.put("otherForeFoot", null);
        map.put("otherHindFoot", null);
        map.put("inside", null);
        map.put("outside", null);
        map.put("pressure",null);

        map.put("leftPressureOnedataFFT",null);
        map.put("leftPressureTwodataFFT",null);
        map.put("leftPressureThreedataFFT",null);
        map.put("leftPressureFourdataFFT",null);
        map.put("leftPressureFivedataFFT",null);
        map.put("leftPressureSixdataFFT",null);
        map.put("leftPressureSevendataFFT",null);
        map.put("leftPressureEightdataFFT",null);
        map.put("leftPressureNinedataFFT",null);
        map.put("rightPressureOnedataFFT",null);
        map.put("rightPressureTwodataFFT",null);
        map.put("rightPressureThreedataFFT",null);
        map.put("rightPressureFourdataFFT",null);
        map.put("rightPressureFivedataFFT",null);
        map.put("rightPressureSixdataFFT",null);
        map.put("rightPressureSevendataFFT",null);
        map.put("rightPressureEightdataFFT",null);
        map.put("rightPressureNinedataFFT",null);

        map.put("weightPercentage_left",null);
        map.put("weightPercentage_right", null);



        map.put("suggestion", "");

        return map;
    }

    /**
     * 三维扫描报告
     * @param patientThree
     * @param mesurementBO
     * @return
     */
    public Map<String, String> getDataMap(PatientThree patientThree, MesurementBO mesurementBO) {
        Map<String, String> map = new HashMap<>();

        /**
         * 基本资料
         */
        map.put("name", patientThree.getName());
        map.put("sex", patientThree.getSex());
        map.put("testDate", patientThree.getTestTime());
        map.put("testWay", "负重位");

        /**
         * 足弓指数
         */
        map.put("archIndexL", mesurementBO.getArchIndexL());
        map.put("archIndexR", mesurementBO.getArchIndexR());

        /**
         * 足弓面积
         */
        map.put("footAreaL", mesurementBO.getFootAreaL());
        map.put("footAreaR", mesurementBO.getFootAreaR());

        /**
         * 全足面积
         */
        map.put("medArchAreaL", mesurementBO.getMedArchAreaL());
        map.put("medArchAreaR", mesurementBO.getMedArchAreaR());

        /**
         * 足弓体积
         */
        map.put("medArchVolumeL", mesurementBO.getMedArchVolumeL());
        map.put("medArchVolumeR", mesurementBO.getMedArchVolumeR());

        /**
         * 平均足弓高度
         */
        map.put("archHeightL", mesurementBO.getArchHeightL());
        map.put("archHeightR", mesurementBO.getArchHeightR());

        /**
         * 长、宽
         */
        map.put("footL", mesurementBO.getFootL());
        map.put("footR", mesurementBO.getFootR());
        map.put("archL", mesurementBO.getArchL());
        map.put("archR", mesurementBO.getArchR());
        map.put("oneHeelTipL", mesurementBO.getOneHeelTipL());
        map.put("oneHeelTipR", mesurementBO.getOneHeelTipR());
        map.put("fiveHeelTipL", mesurementBO.getFiveHeelTipL());
        map.put("fiveHeelTipR", mesurementBO.getFiveHeelTipR());
        map.put("hcHeelTipL", mesurementBO.getHcHeelTipL());
        map.put("hcHeelTipR", mesurementBO.getHcHeelTipR());
        map.put("latArchHeelTipL", mesurementBO.getLatArchHeelTipL());
        map.put("latArchHeelTipR", mesurementBO.getLatArchHeelTipR());
        map.put("medArchHeelTipL", mesurementBO.getMedArchHeelTipL());
        map.put("medArchHeelTipR", mesurementBO.getMedArchHeelTipR());

        map.put("foreFootL", mesurementBO.getForeFootL());
        map.put("foreFootR", mesurementBO.getForeFootR());
        map.put("heelL", mesurementBO.getHeelL());
        map.put("heelR", mesurementBO.getHeelR());
        map.put("midFootL", mesurementBO.getMidFootL());
        map.put("midFootR", mesurementBO.getMidFootR());
        map.put("oneToFiveMetL", mesurementBO.getOneToFiveMetL());
        map.put("oneToFiveMetR", mesurementBO.getOneToFiveMetR());

        /**
         * 拇外翻指数
         */
        map.put("halluxAngleL", mesurementBO.getHalluxAngleL());
        map.put("halluxAngleR", mesurementBO.getHalluxAngleR());

        /**
         * 图片
         */
        map.put("leftindex", null);
        map.put("rightindex", null);
        map.put("lArchImg", null);
        map.put("rArchImg", null);
        map.put("footDataL1", null);
        map.put("footDataR1", null);
        map.put("footDataL2", null);
        map.put("footDataR2", null);

        return map;
    }

    /**
     * 获取当前时间的年月日
     * @return
     */
    private String getTestDate() {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        return df.format(new Date());
    }

    /**
     * 根据时间字符串获取 年、月、日、星期
     * @param dateStr
     * @return
     */
    private Map<String, String> getDate(String dateStr) {

        Map<String, String> map = new HashMap<>();

        String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};

//        String subDateStr = dateStr.substring(0, 8); // 只要年月日

        StringToDateConverter dateConverter = new StringToDateConverter();
        Date date = dateConverter.convert(dateStr);

        Calendar c = Calendar.getInstance();
        c.setTime(date); // 设置 Date为 Calendar

        map.put("year", String.valueOf(c.get(Calendar.YEAR)));
        map.put("month", String.valueOf(c.get(Calendar.MONTH) + 1));
        map.put("day", String.valueOf(c.get(Calendar.DAY_OF_MONTH)));
        map.put("weekDay", weekDays[c.get(Calendar.DAY_OF_WEEK)-1]);

        return map;
    }

    /**
     * 获取左右脚的平均压力
     * @param featureData
     * @return
     */
    private List<String> getMeanPressure(FeatureData featureData) {
        List<String> pressure = new ArrayList<>();
        double leftPressureValue = 0;
        double rightPressureValue = 0;

        // 左脚
        List<String> leftPressureList = new ArrayList<>();
        leftPressureList.add(featureData.getPressureMeanLeft1());
        leftPressureList.add(featureData.getPressureMeanLeft2());
        leftPressureList.add(featureData.getPressureMeanLeft3());
        leftPressureList.add(featureData.getPressureMeanLeft4());
        leftPressureList.add(featureData.getPressureMeanLeft5());
        leftPressureList.add(featureData.getPressureMeanLeft6());
        leftPressureList.add(featureData.getPressureMeanLeft7());
        leftPressureList.add(featureData.getPressureMeanLeft8());
        leftPressureList.add(featureData.getPressureMeanLeft9());


        // 右脚
        List<String> rightPressureList = new ArrayList<>();
        rightPressureList.add(featureData.getPressureMeanRigh1());
        rightPressureList.add(featureData.getPressureMeanRight2());
        rightPressureList.add(featureData.getPressureMeanRight3());
        rightPressureList.add(featureData.getPressureMeanRight4());
        rightPressureList.add(featureData.getPressureMeanRight5());
        rightPressureList.add(featureData.getPressureMeanRight6());
        rightPressureList.add(featureData.getPressureMeanRight7());
        rightPressureList.add(featureData.getPressureMeanRight8());
        rightPressureList.add(featureData.getPressureMeanRight9());


        for (int i=0; i<leftPressureList.size(); i++) {
            leftPressureValue += Double.parseDouble(leftPressureList.get(i));
            rightPressureValue += Double.parseDouble(rightPressureList.get(i));
        }

        pressure.add(0,getTwoDigits((leftPressureValue / (leftPressureValue + rightPressureValue)) * 100) + "%");//左脚总压力站两只脚的比重
        pressure.add(1,getTwoDigits((rightPressureValue / (leftPressureValue + rightPressureValue) * 100)) + "%");//右脚总压力站两只脚的比重
        pressure.add(2,getTwoDigits(leftPressureValue));//JD123456789-APZH-L  --节点123456789平均压力总和-左    -----------新---------------------------
        pressure.add(3,getTwoDigits(rightPressureValue));//JD123456789-APZH-R  --节点123456789平均压力总和-右
        pressure.add(4,getTwoDigits(((Double.parseDouble(leftPressureList.get(0)))/leftPressureValue)*100)+"%");//JD1-APR-L  --节点1平均压力比值-左
        pressure.add(5,getTwoDigits(((Double.parseDouble(leftPressureList.get(1)))/leftPressureValue)*100)+"%");//JD2-APR-L  --节点2平均压力比值-左
        pressure.add(6,getTwoDigits(((Double.parseDouble(leftPressureList.get(2)))/leftPressureValue)*100)+"%");//JD3-APR-L  --节点3平均压力比值-左
        pressure.add(7,getTwoDigits(((Double.parseDouble(leftPressureList.get(3)))/leftPressureValue)*100)+"%");//JD4-APR-L  --节点4平均压力比值-左
        pressure.add(8,getTwoDigits(((Double.parseDouble(leftPressureList.get(4)))/leftPressureValue)*100)+"%");//JD5-APR-L  --节点5平均压力比值-左
        pressure.add(9,getTwoDigits(((Double.parseDouble(leftPressureList.get(5)))/leftPressureValue)*100)+"%");//JD6-APR-L  --节点6平均压力比值-左
        pressure.add(10,getTwoDigits(((Double.parseDouble(leftPressureList.get(6)))/leftPressureValue)*100)+"%");//JD7-APR-L  --节点7平均压力比值-左
        pressure.add(11,getTwoDigits(((Double.parseDouble(leftPressureList.get(7)))/leftPressureValue)*100)+"%");//JD8-APR-L  --节点8平均压力比值-左
        pressure.add(12,getTwoDigits(((Double.parseDouble(leftPressureList.get(8)))/leftPressureValue)*100)+"%");//JD9-APR-L  --节点9平均压力比值-左
        pressure.add(13,getTwoDigits(((Double.parseDouble(rightPressureList.get(0)))/rightPressureValue)*100)+"%");//JD1-APR-R  --节点1平均压力比值-右
        pressure.add(14,getTwoDigits(((Double.parseDouble(rightPressureList.get(1)))/rightPressureValue)*100)+"%");//JD2-APR-R  --节点2平均压力比值-右
        pressure.add(15,getTwoDigits(((Double.parseDouble(rightPressureList.get(2)))/rightPressureValue)*100)+"%");//JD3-APR-R  --节点3平均压力比值-右
        pressure.add(16,getTwoDigits(((Double.parseDouble(rightPressureList.get(3)))/rightPressureValue)*100)+"%");//JD4-APR-R  --节点4平均压力比值-右
        pressure.add(17,getTwoDigits(((Double.parseDouble(rightPressureList.get(4)))/rightPressureValue)*100)+"%");//JD5-APR-R  --节点5平均压力比值-右
        pressure.add(18,getTwoDigits(((Double.parseDouble(rightPressureList.get(5)))/rightPressureValue)*100)+"%");//JD6-APR-R  --节点6平均压力比值-右
        pressure.add(19,getTwoDigits(((Double.parseDouble(rightPressureList.get(6)))/rightPressureValue)*100)+"%");//JD7-APR-R  --节点7平均压力比值-右
        pressure.add(20,getTwoDigits(((Double.parseDouble(rightPressureList.get(7)))/rightPressureValue)*100)+"%");//JD8-APR-R  --节点8平均压力比值-右
        pressure.add(21,getTwoDigits(((Double.parseDouble(rightPressureList.get(8)))/rightPressureValue)*100)+"%");//JD9-APR-R  --节点9平均压力比值-右

        pressure.add(22,getTwoDigits(((Double.parseDouble(leftPressureList.get(3)))+(Double.parseDouble(leftPressureList.get(4)))+(Double.parseDouble(leftPressureList.get(5))))));//JD456-APZH-L  --节点456平均压力总和-左
        pressure.add(23,getTwoDigits(((Double.parseDouble(rightPressureList.get(3)))+(Double.parseDouble(rightPressureList.get(4)))+(Double.parseDouble(rightPressureList.get(5))))));//JD456-APZH-R  --节点456平均压力总和-右
        pressure.add(24,getTwoDigits((((Double.parseDouble(leftPressureList.get(3)))+(Double.parseDouble(leftPressureList.get(4)))+(Double.parseDouble(leftPressureList.get(5))))/leftPressureValue)*100)+"%");//JD456-APR-L  --节点456平均压力比值-左
        pressure.add(25,getTwoDigits((((Double.parseDouble(rightPressureList.get(3)))+(Double.parseDouble(rightPressureList.get(4)))+(Double.parseDouble(rightPressureList.get(5))))/rightPressureValue)*100)+"%");//JD456-APR-R  --节点456平均压力比值-右

        pressure.add(26,getTwoDigits(((Double.parseDouble(leftPressureList.get(0)))+(Double.parseDouble(leftPressureList.get(1)))+(Double.parseDouble(leftPressureList.get(7)))+(Double.parseDouble(leftPressureList.get(8))))));//JD1289-APZH-L  --节点1289平均压力总和-左
        pressure.add(27,getTwoDigits(((Double.parseDouble(rightPressureList.get(0)))+(Double.parseDouble(rightPressureList.get(1)))+(Double.parseDouble(rightPressureList.get(7)))+(Double.parseDouble(rightPressureList.get(8))))));//JD1289-APZH-R  --节点1289平均压力总和-右
        pressure.add(28,getTwoDigits((((Double.parseDouble(leftPressureList.get(0)))+(Double.parseDouble(leftPressureList.get(1)))+(Double.parseDouble(leftPressureList.get(7)))+(Double.parseDouble(leftPressureList.get(8))))/leftPressureValue)*100)+"%");//JD1289-APR-L  --节点1289平均压力比值-左
        pressure.add(29,getTwoDigits((((Double.parseDouble(rightPressureList.get(0)))+(Double.parseDouble(rightPressureList.get(1)))+(Double.parseDouble(rightPressureList.get(7)))+(Double.parseDouble(rightPressureList.get(8))))/rightPressureValue)*100)+"%");//JD1289-APR-R  --节点1289平均压力比值-右

        pressure.add(30,getTwoDigits(((Double.parseDouble((featureData.getPressureAddLeft())))/(Double.parseDouble((featureData.getPressureAddRight()))))*100)+"%");//JDYLZHR  --节点压力总和比值

        pressure.add(31,getTwoDigits(((Double.parseDouble((featureData.getPressureHeelInsideLoadAddLeft())))/(Double.parseDouble((featureData.getPressureHeelOutsideLoadAddLeft()))))*100)+"%");//CPQ-MLP-YLZHR-L  --触地期内外侧压力总和比值-左
        pressure.add(32,getTwoDigits(((Double.parseDouble((featureData.getPressureHeelInsideLoadAddRight())))/(Double.parseDouble((featureData.getPressureHeelOutsideLoadAddRight()))))*100)+"%");//CPQ-MLP-YLZHR-R  --触地期内外侧压力总和比值-右
        pressure.add(33,getTwoDigits(((Double.parseDouble((featureData.getPressureHeelInsideFootflatAddLeft())))/(Double.parseDouble((featureData.getPressureHeelOutsideFootflatAddLeft()))))*100)+"%");//MPQ-MLP-YLZHR-L  --站立中期内外侧压力总和比值-左
        pressure.add(34,getTwoDigits(((Double.parseDouble((featureData.getPressureHeelInsideFootflatAddRight())))/(Double.parseDouble((featureData.getPressureHeelOutsideFootflatAddRight()))))*100)+"%");//MPQ-MLP-YLZHR-R  --站立中期内外侧压力总和比值-右
        pressure.add(35,getTwoDigits((((Double.parseDouble((featureData.getPressureHeelInsideLoadAddLeft())))+(Double.parseDouble((featureData.getPressureHeelInsideFootflatAddLeft()))))/((Double.parseDouble((featureData.getPressureHeelOutsideLoadAddLeft())))+(Double.parseDouble((featureData.getPressureHeelOutsideFootflatAddLeft())))))*100)+"%");//CMPQ-MLP-YLZHR-L  --触地期+站立中期内外侧压力总和比值-左
        pressure.add(36,getTwoDigits((((Double.parseDouble((featureData.getPressureHeelInsideLoadAddRight())))+(Double.parseDouble((featureData.getPressureHeelInsideFootflatAddRight()))))/((Double.parseDouble((featureData.getPressureHeelOutsideLoadAddRight())))+(Double.parseDouble((featureData.getPressureHeelOutsideFootflatAddRight())))))*100)+"%");//CMPQ-MLP-YLZHR-R  --触地期+站立中期内外侧压力总和比值-右

        pressure.add(37,getTwoDigits(((Double.parseDouble((featureData.getPressureInsideAddLeft())))/(Double.parseDouble((featureData.getPressureOutsideAddLeft()))))*100)+"%");//MLP-YLZHR-L  --内外侧压力总和比值-左
        pressure.add(38,getTwoDigits(((Double.parseDouble((featureData.getPressureInsideAddRight())))/(Double.parseDouble((featureData.getPressureOutsideAddRight()))))*100)+"%");//MLP-YLZHR-R  --内外侧压力总和比值-右

        return pressure;
    }

    /**
     * 获取前中后足的平均压力
     * @param featureData
     * @return
     */
    private List<String> getQZHMeanPressure(FeatureData featureData) {
        List<String> pressure = new ArrayList<>();

        List<String> leftPressureList = new ArrayList<>();
        leftPressureList.add(featureData.getPressureMeanLeft1());
        leftPressureList.add(featureData.getPressureMeanLeft2());
        leftPressureList.add(featureData.getPressureMeanLeft3());
        leftPressureList.add(featureData.getPressureMeanLeft4());
        leftPressureList.add(featureData.getPressureMeanLeft5());
        leftPressureList.add(featureData.getPressureMeanLeft6());
        leftPressureList.add(featureData.getPressureMeanLeft7());
        leftPressureList.add(featureData.getPressureMeanLeft8());
        leftPressureList.add(featureData.getPressureMeanLeft9());

        List<String> rightPressureList = new ArrayList<>();
        rightPressureList.add(featureData.getPressureMeanRigh1());
        rightPressureList.add(featureData.getPressureMeanRight2());
        rightPressureList.add(featureData.getPressureMeanRight3());
        rightPressureList.add(featureData.getPressureMeanRight4());
        rightPressureList.add(featureData.getPressureMeanRight5());
        rightPressureList.add(featureData.getPressureMeanRight6());
        rightPressureList.add(featureData.getPressureMeanRight7());
        rightPressureList.add(featureData.getPressureMeanRight8());
        rightPressureList.add(featureData.getPressureMeanRight9());

        double forePressureValue = Double.parseDouble(leftPressureList.get(1)) + Double.parseDouble(leftPressureList.get(7)) + Double.parseDouble(leftPressureList.get(8)) +
                Double.parseDouble(rightPressureList.get(1)) + Double.parseDouble(rightPressureList.get(7)) + Double.parseDouble(rightPressureList.get(8));

        double forePressureValue1 = Double.parseDouble(leftPressureList.get(0)) + Double.parseDouble(leftPressureList.get(1)) + Double.parseDouble(leftPressureList.get(7)) + Double.parseDouble(leftPressureList.get(8)) +
                Double.parseDouble(rightPressureList.get(0)) + Double.parseDouble(rightPressureList.get(1)) + Double.parseDouble(rightPressureList.get(7)) + Double.parseDouble(rightPressureList.get(8));

        double midPressureValue = Double.parseDouble(leftPressureList.get(2)) + Double.parseDouble(leftPressureList.get(6)) +
                Double.parseDouble(rightPressureList.get(2)) + Double.parseDouble(rightPressureList.get(6));

        double hindPressureValue = Double.parseDouble(leftPressureList.get(3)) + Double.parseDouble(leftPressureList.get(4)) + Double.parseDouble(leftPressureList.get(5)) +
                Double.parseDouble(rightPressureList.get(3)) + Double.parseDouble(rightPressureList.get(4)) + Double.parseDouble(rightPressureList.get(5));

        pressure.add(getTwoDigits((forePressureValue / (forePressureValue + midPressureValue + hindPressureValue)) * 100) + "%");
        pressure.add(getTwoDigits((midPressureValue / (forePressureValue + midPressureValue + hindPressureValue) * 100)) + "%");
        pressure.add(getTwoDigits((hindPressureValue / (forePressureValue + midPressureValue + hindPressureValue)) * 100) + "%");
        pressure.add(getTwoDigits((forePressureValue1 / (forePressureValue1 + hindPressureValue)) * 100) + "%");
        pressure.add(getTwoDigits((hindPressureValue / (forePressureValue1 + hindPressureValue))* 100) + "%");

        return pressure;
    }

    /**
     * 获取内外足的平均压力
     * @param featureData
     * @return
     */
    private List<String> getNWMeanPressure(FeatureData featureData) {
        List<String> pressure = new ArrayList<>();
        double insidePressure = 0;
        double outsidePressure = 0;

        List<String> leftPressureList = new ArrayList<>();
        leftPressureList.add(featureData.getPressureMeanLeft1());
        leftPressureList.add(featureData.getPressureMeanLeft2());
        leftPressureList.add(featureData.getPressureMeanLeft3());
        leftPressureList.add(featureData.getPressureMeanLeft4());
        leftPressureList.add(featureData.getPressureMeanLeft5());
        leftPressureList.add(featureData.getPressureMeanLeft6());
        leftPressureList.add(featureData.getPressureMeanLeft7());
        leftPressureList.add(featureData.getPressureMeanLeft8());
        leftPressureList.add(featureData.getPressureMeanLeft9());

        List<String> rightPressureList = new ArrayList<>();
        rightPressureList.add(featureData.getPressureMeanRigh1());
        rightPressureList.add(featureData.getPressureMeanRight2());
        rightPressureList.add(featureData.getPressureMeanRight3());
        rightPressureList.add(featureData.getPressureMeanRight4());
        rightPressureList.add(featureData.getPressureMeanRight5());
        rightPressureList.add(featureData.getPressureMeanRight6());
        rightPressureList.add(featureData.getPressureMeanRight7());
        rightPressureList.add(featureData.getPressureMeanRight8());
        rightPressureList.add(featureData.getPressureMeanRight9());

        for (int i=0; i<4; i++) {
            insidePressure += Double.parseDouble(leftPressureList.get(i));
        }
        for (int i=5; i<8; i++) {
            outsidePressure += Double.parseDouble(rightPressureList.get(i));
        }

        pressure.add(getTwoDigits((insidePressure / (insidePressure + outsidePressure)) * 100) + "%");
        pressure.add(getTwoDigits((outsidePressure / (insidePressure + outsidePressure)) * 100) + "%");

        return pressure;
    }

    /**
     * 获取基础数据的平均时间
     * @param rundurationtimeLeft
     * @param rundurationtimeRight
     * @return
     */
    private String getAverageTime(String rundurationtimeLeft, String rundurationtimeRight) {
        double sum = Double.parseDouble(rundurationtimeLeft) + Double.parseDouble(rundurationtimeRight);
        double averageTime = NumberUtil.div(sum, 2, 2);
        return String.valueOf(averageTime);
    }

    /**
     * 获取基础数据的平均速度
     * @param stepSpeedLeft
     * @param stepSpeedRight
     * @return
     */
    private String getAverageSpeed(String stepSpeedLeft, String stepSpeedRight) {
        double sum = Double.parseDouble(stepSpeedLeft) + Double.parseDouble(stepSpeedRight);
        double averageSpeed = NumberUtil.div(sum, 2, 2);
        return String.valueOf(averageSpeed);
    }

    /**
     *
     * @param featureData
     * @return
     */
    private List<String> getGaitCycleInfo(FeatureData featureData) {
        List<String> list = new ArrayList<>();

        double MDGP_L = Double.parseDouble(featureData.getRundurationtimeLeft()) / Double.parseDouble(featureData.getStepNumberLeft());
        list.add(0, getTwoDigits(MDGP_L));  // MDGP-L --平均步态周期时长-左
        double MDGP_R = Double.parseDouble(featureData.getRundurationtimeRight()) / Double.parseDouble(featureData.getStepNumberRight());
        list.add(1, getTwoDigits(MDGP_R));  // MDGP-R  --平均步态周期时长-右

        double ADCPQ_L = MDGP_L * Double.parseDouble(featureData.getLoadingRatioLeftMean());
        list.add(2, getTwoDigits(ADCPQ_L)); // ADCPQ_L  --平均触地期时长-左
        double ADCPQ_R = MDGP_R * Double.parseDouble(featureData.getLoadingRatioRightMean());
        list.add(3, getTwoDigits(ADCPQ_R)); // ADCPQ_R  --平均触地期时长-右

        double ADMPQ_L = MDGP_L * Double.parseDouble(featureData.getFootflatRatioLeftMean());
        list.add(4, getTwoDigits(ADMPQ_L)); // ADMPQ_L  --平均站立中期时长-左
        double ADMPQ_R = MDGP_R * Double.parseDouble(featureData.getFootflatRatioRightMean());
        list.add(5, getTwoDigits(ADMPQ_R)); // ADMPQ_R  --平均站立中期时长-右

        double ADPPQ_L = MDGP_L * Double.parseDouble(featureData.getPreSwingRatioLeftMean());
        list.add(6, getTwoDigits(ADPPQ_L)); // ADPPQ_L  --平均推进期时长-左
        double ADPPQ_R = MDGP_R * Double.parseDouble(featureData.getPreSwingRatioRightMean());
        list.add(7, getTwoDigits(ADPPQ_R)); // ADPPQ_R  --平均推进期时长-右

        double ADSPQ_L = MDGP_L * Double.parseDouble(featureData.getSwingRatioLeftMean());
        list.add(8, getTwoDigits(ADSPQ_L)); // ADSPQ_L  --平均摆动期时长-左
        double ADSPQ_R = MDGP_R * Double.parseDouble(featureData.getSwingRatioRightMean());
        list.add(9, getTwoDigits(ADSPQ_R)); // ADSPQ_R  --平均摆动期时长-右

        return list;
    }

    /**
     *站立相
     * @param featureData
     * @return
     */
    private List<String> getGaitSDPinfo(FeatureData featureData) {
        List<String> SDPlist = new ArrayList<>();

        SDPlist.add( 0,getTwoDigits((Double.parseDouble(featureData.getLoadingRatioLeftMean()) + Double.parseDouble(featureData.getFootflatRatioLeftMean())+ Double.parseDouble(featureData.getPreSwingRatioLeftMean()))*100)+ "%");
          // SDP-L
        SDPlist.add(1,getTwoDigits((Double.parseDouble(featureData.getLoadingRatioRightMean()) + Double.parseDouble(featureData.getFootflatRatioRightMean())+ Double.parseDouble(featureData.getPreSwingRatioRightMean()))*100)+ "%");
          // SDP-R
        return SDPlist;
    }

    /**
     *后脚跟角速度
     * @param featureData
     * @return
     */
    private List<String> getGaitHeelPalstanceInfo(FeatureData featureData) {
        List<String> HeelPalstanceList = new ArrayList<>();

        double HVNF_CZWAR_L = Double.parseDouble(featureData.getALeftMean()) / Double.parseDouble(featureData.getT1LeftMean());
        HeelPalstanceList.add(0, getTwoDigits(HVNF_CZWAR_L));  // HVNF_CZWAR_L  --后跟内翻至垂直位角速率-左
        double HVW_ZDWFAR_L = Double.parseDouble(featureData.getBLeftMean()) / Double.parseDouble(featureData.getT2LeftMean());
        HeelPalstanceList.add(1, getTwoDigits(HVW_ZDWFAR_L));  // HVW_ZDWFAR_L  --后跟内翻至垂直位角速率-右
        double HVNF_ZDWFAR_L = Double.parseDouble(featureData.getCLeftMean()) / Double.parseDouble(featureData.getT3LeftMean());
        HeelPalstanceList.add(2, getTwoDigits(HVNF_ZDWFAR_L));  // HVNF_ZDWFAR_L  --后跟垂直位至最大外翻角速率-左
        double HVNF_CZWAR_R = Double.parseDouble(featureData.getARightMean()) / Double.parseDouble(featureData.getT1RightMean());
        HeelPalstanceList.add(3, getTwoDigits(HVNF_CZWAR_R));  // HVNF_CZWAR_R  --后跟垂直位至最大外翻角速率-右
        double HVW_ZDWFAR_R = Double.parseDouble(featureData.getBRightMean()) / Double.parseDouble(featureData.getT2RightMean());
        HeelPalstanceList.add(4, getTwoDigits(HVW_ZDWFAR_R));  // HVW_ZDWFAR_R  --后跟内翻至最大外翻角速率-左
        double HVNF_ZDWFAR_R = Double.parseDouble(featureData.getCRightMean()) / Double.parseDouble(featureData.getT3RightMean());
        HeelPalstanceList.add(5, getTwoDigits(HVNF_ZDWFAR_R));  // HVNF_ZDWFAR_R  --后跟内翻至最大外翻角速率-右

        double HVNF_ZDNFAR_L = Double.parseDouble(featureData.getC1LeftMean()) / Double.parseDouble(featureData.getT31LeftMean());
        HeelPalstanceList.add(6, getTwoDigits(HVNF_ZDNFAR_L));  // HVNF_ZDNFAR_L  --后跟内翻至最大内翻角速率-左
        double HVNF_ZDNFAR_R = Double.parseDouble(featureData.getC1RightMean()) / Double.parseDouble(featureData.getT31RightMean());
        HeelPalstanceList.add(7, getTwoDigits(HVNF_ZDNFAR_R));  // HVNF_ZDNFAR_R  --后跟内翻至最大内翻角速率-右

        return HeelPalstanceList;
    }

    /**
     * 保留2位小数
     * @param num
     * @return
     */
    private String getTwoDigits(double num) {
        if(Double.isNaN(num)|| Double.isInfinite(num)) {
            num=0.00;
        }
        return NumberUtil.roundStr(num, 2);
    }

    /**
     * 保留2位小数
     * @param numStr
     * @return
     */
    private String getTwoDigits(String numStr) {
        if(numStr==null || numStr.equals("") ) {
            return "";
        }
        return NumberUtil.roundStr(numStr, 2);
    }

    /**
     * 保留3位小数
     * @param numStr
     * @return
     */
    private String getThreeDigits(String numStr) {
        if(numStr==null || numStr.equals("") ) {
            return "";
        }
        return NumberUtil.roundStr(numStr, 3);
    }

}
